<?php

/**
 * @package Framework03
 * @author Walter Tamboer
 */

/**
 * Used to render PHP templates
 */
class PhpRenderDevice extends RenderDevice
{
	/**
	 * @var string The path of the PHP file to parse.
	 */
	private $FilePath;
	/**
	 * Initializes a new instance of this class.
	 * @param array $Data The array with variables that can be used in this render device.
	 */
	public function __construct($FilePath, array $Data = array())
	{
		parent::__construct($Data);

		$this->FilePath = $FilePath;
	}
	/**
	 * Gets the rendered content.
	 * @return string Returns a string with the parsed content.
	 */
	public function Render()
	{
		extract($this->Data);

		if (!is_file($this->FilePath))
			throw new Exception('Trying to render "' . $this->FilePath . '" which doesn\'t exist.', 404);

		ob_start();
		include($this->FilePath);
		$Source = ob_get_contents();
		ob_end_clean();

		echo $Source;
	}
}

?>